<%--
  Created by IntelliJ IDEA.
  User: 武露斌
  Date: 2021/10/20
  Time: 16:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="../../js/jquery-1.8.2.min.js"></script>
    <script src="../../js/fileupload.js"></script>
    <link rel="stylesheet" href="../../css/css.css">
    <link rel="stylesheet" href="../../css/img.css">
</head>
<body>

<form>
    ID:<input type="text" name="sid" value="${param.sid}"><br>
    拍摄地点：<input type="text" name="sname"><br>
    具体地址：<input type="text" name="saddress"><br>
    场景费用：<input type="text" name="smoney"><br><br>
    照片：
    <div class="photoUpLoad" >
        <input type="file"   class="photo" name="photo" accept="image/*"><span class="cross">+</span>
        <img src="" alt="" class="photoEcho">
    </div><br>
    用户：
    <div name="uid">

    </div>

</form>
<input type="button" value="修改" onclick="upda()">


</body>
</html>

<script>

    $.ajaxSettings.async=false

    $.post(
        "listuser.do",
        function (data) {
            for (var i = 0; i <data.length; i++) {
                $("[name='uid']").append('<input type="checkbox" name="uids" value="'+data[i].uid+'">'+data[i].uname)
            }
        }
    )

    $.post(
        "huips.do",
        {"sid":${param.sid}},
        function (data) {
            console.log(data)
            $("[name='sname']").val(data.sname)
            $("[name='saddress']").val(data.saddress)
            $("[name='smoney']").val(data.smoney)
            $(".photoEcho").prop("src",data.spic)

           var uids= data.uids.split(",")
            for (var i = 0; i <uids.length ; i++) {
                $("[name='uids'][value="+uids[i]+"]").prop("checked",true)
            }
        }
    )

    function upda() {
        var formData = new FormData($("form")[0]);

        $.ajax({
            url:"updaps.do",
            data:formData,
            type:"post",
            dataType:"json",
            success:function (data) {
                if (data>0){
                    alert("修改成功")
                    location="list.do"
                }else{
                    alert("修改失败")
                }
            },processData:false,contentType:false
        })
    }

</script>
